#!/bin/bash
yum -y install net-tools&>/dev/null
netstat -tnlp|grep httpd &>/dev/null
if [ $? -eq 0 ]
then
    echo "httpd正在运行"
#httpd server running
else
    echo "httpd停止运行"
#httpd server sleeping
read -p "httpd server need run(yes/no)?" switch
case $switch in
Y|y|yes|YES)
    systemctl start httpd
    if [ $? -eq 0 ]
    then
        echo "httpd启动完成"
#httpd server start
    else
        echo "httpd启动失败,请检查是否安装httpd服务"
#httpd server not start,you need install httpd server
    fi
;;
N|n|no|NO)
    echo "退出" && exit
;;
esac
fi